package ch05;

public class FibonacciGenerator {
	
	private int fold1;
	private int fold2;
	private int foldNew;
	
	private int nCount = 1;
	
	public FibonacciGenerator()
	{
		fold1 = 1;
		fold2 = 1;
	}
	
	public int nextFibonacciNumber()
	{
		if(nCount < 3)
		{
			foldNew = 1;
		} else {
			foldNew = fold1 + fold2;
			
			fold1 = fold2;
			fold2 = foldNew;
		}
		nCount ++;
		return foldNew;
	}

}
